<template>
  <div class="layout">
    <Layout>
      <Content :style="{padding: '0 50px'}">
        <Card>
          <div style="min-height: 200px;">
            <v-table
              is-horizontal-resize
              style="width:100%"
              :columns="columns"
              :table-data="tableData"
              row-hover-color="#eee"
              row-click-color="#edf7ff"
            ></v-table>
          </div>
        </Card>
      </Content>
    </Layout>
  </div>
</template>

<script>
  export default {
    name: "MainPage",
    data() {
      return {
        tableData: [],
        columns: [
          {field: 'id', title: '编号', width: 80, titleAlign: 'center', columnAlign: 'center',isResize:true},
          {field: 'username', title: '姓名', width: 280, titleAlign: 'center', columnAlign: 'left',isResize:true},
          {field: 'password', title: '密码', width: 150, titleAlign: 'center', columnAlign: 'center',isResize:true},
          {field: 'email', title: '邮箱', width: 150, titleAlign: 'center', columnAlign: 'center',isResize:true}
        ]
      }
    },
    created() {
        //这里直接在created函数中使用axios的get请求向后台获取用户信息数据
        // 在实际开发中可以卸载apiadress.js中配置具体的method对应的路径和接口，这个
        //后面完善功能的情况下再进行介绍
        this.$ajax('http://localhost:8080/user/getAll').then(res => {
        //this.$axios.get('/user/getAll').then(res => {
         this.tableData = res.data
          console.log(res.data);
       }).catch(function (error) {
          console.log(error);
     });
  }
  }
</script>
<style scoped>
  .layout{
    border: 1px solid #d7dde4;
    background: #f5f7f9;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    height: 100%;
  }
  .layout-logo{
    width: 100px;
    height: 30px;
    background: #5b6270;
    border-radius: 3px;
    float: left;
    position: relative;
    top: 15px;
    left: 20px;
    font-weight: bold;
    text-align: center;
    color: #49ffcc;
  }
  .layout-nav{
    width: 420px;
    margin: 0 auto;
    margin-right: 20px;
  }
  .layout-footer-center{
    text-align: center;
  }
</style>